package com.smile.frame.alibaba.services.gateway.gray;

import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;


/**
 * 全局服务灰度发布
 * @author LGC
 */
public class GlobalServiceInstanceListSupplierConfiguration {

    @Bean
    ServiceInstanceListSupplier serviceInstanceListSupplier(ConfigurableApplicationContext context) {
        ReactiveDiscoveryClient reactiveDiscoveryClient = context.getBean(ReactiveDiscoveryClient.class);
        return new GrayServiceInstanceListSupplier(reactiveDiscoveryClient, context.getEnvironment());
    }
}
